﻿// -----------------------------------------------------------------------
// <copyright file="SystemClock.cs" company="SoftServe">
// System Clock
// </copyright>
// -----------------------------------------------------------------------
namespace WebServer.BusinessLogic.Helpers
{
    using System;

    /// <summary>
    /// Interface for time
    /// </summary>
    public interface IClock
    {
        /// <summary>
        /// Gets data time
        /// </summary>
        DateTime Now { get; }
    }

    /// <summary>
    /// Class which realize time
    /// </summary>
    public class SystemClock : IClock
    {
        /// <summary>
        /// Gets current time
        /// </summary>
        public DateTime Now
        {
            get { return DateTime.Now; }
        }
    }

    /// <summary>
    /// Class for faking clock
    /// </summary>
    public class FakeClock : IClock
    {
        /// <summary>
        /// field for time
        /// </summary>
        private readonly DateTime fakeDateTime;

        /// <summary>
        /// Initializes a new instance of the <see cref="FakeClock" /> class.
        /// </summary>
        /// <param name="fakeDateTime">fake time</param>
        public FakeClock(DateTime fakeDateTime)
        {
            this.fakeDateTime = fakeDateTime;
        }

        /// <summary>
        /// Gets fake time
        /// </summary>
        public virtual DateTime Now
        {
            get
            {
                return this.fakeDateTime;
            }
        }
    }
}
